package org.cuatrovientos.empire_fleet;

import java.util.Scanner;
import java.util.Vector;

/**
 * Represents an imperial fleet composed
 * of many space_ships
 * @author Sienar Fleet Systems
 * @greets the emperor
 */
public class Fleet extends Vector<SpaceShip> {
	private String commander_name;
	
	/**
	 * creates fleet
	 * three steps: define commander name, create fleet, show fleet
	 */
	public void create_fleet () {
		Scanner reader = new Scanner(System.in);
		String option = "";
		String line = "";
		
		// Give commander name
		do {
			System.out.println("Identify yourself");
			commander_name = reader.nextLine();
		} while (commander_name.isEmpty());
		
		// We start a loop to define the fleet
		// In each loop commander chooses one kind of ship to be added
		// to his fleet
		do {
			System.out.println("What kind of ship do you want?");
			System.out.println("1.TF \n 2.TA \n 3.TB \n 4.Exit\n");
			option = reader.nextLine();
			
			switch (option) {
				case "1": // a tie fighter
						System.out.println("Name of the pilot: "); 
						line = reader.nextLine();
						this.add(new TieFighter(line));
						break;
				case "2":
						System.out.println("Name of the pilot: "); 
						line = reader.nextLine();
						this.add(new TieAdvanced(line));
						break;
				case "3":
						System.out.println("Name of the pilot: "); 
						line = reader.nextLine();
						this.add(new TieBomber(line));
						break;
				case "4":
						System.out.println("Ended.");
						break;
				default:
						System.out.println("Option incorrect");
			}
		} while(!option.equals("4"));
		
		// Resume: show complete fleet info
		// using foreach like for
		for (SpaceShip ship : this) {
			System.out.println("Type: " + ship.getType() + "," + ship.toString());
		}
	}
}
